use bool, true, false. (#272)
authortsteven4 <tsteven4@users.noreply.github.com>
Sat, 17 Nov 2018 22:06:31 +0000 (15:06 -0700)
committerGitHub <noreply@github.com>
Sat, 17 Nov 2018 22:06:31 +0000 (15:06 -0700)
garmin_xt.cc
globalsat_sport.cc
navilink.cc
navilink.h
sbn.cc
sbp.cc

index 76b1773eb1ce64587d23bdff2a0da3c295880236..984cbcd79a7b8481eb6f6abd06fb50a77763fb81 100644 (file)
@@ -261,7 +261,7 @@ format_garmin_xt_proc_strk()
     track_add_head(tmp_track);
 
     // This is the 1st coordinate of the track
-    int FirstCoo = TRUE;
+    bool FirstCoo = true;
     while (trackbytes>0) {
       if (trackbytes>=STRK_BLOCK_SIZE) {
         Count = gbfread(&TrackBlock, DATABLOCKSIZE, STRK_BLOCK_SIZE, fin);
@@ -293,7 +293,7 @@ format_garmin_xt_proc_strk()
           // add way point to the track
           track_add_wpt(tmp_track, wpt);
         } else {
-          FirstCoo = FALSE;
+          FirstCoo = false;
         }
         PrevLat = Lat;
         PrevLon = Lon;
index bcda37a91cf0fe3680dc11c61c74c7ba45346410..67282c78855276800ffa5d49c3271754378e322c 100644 (file)
@@ -45,7 +45,7 @@
 #define MYNAME "GlobalsatSport"
 
 static void* serial_handle;
-static int isSizeSwaped;
+static bool isSizeSwapped;
 
 static char* showlist = nullptr;               // if true show a list instead of download tracks
 static char* track = nullptr;                     // if not 0 only download this track, if 0 download all
@@ -286,13 +286,13 @@ globalsat_write_package(uint8_t* payload, uint32_t size)
 {
   //All globalsat devices but gh561
   //2 <len_h> <len_l> <payload...> <crc>
-  // gh561 (isSizeSwaped)
+  // gh561 (isSizeSwapped)
   //2 <len_l> <len_h> <payload...> <crc>
 
   uint8_t crc = 0;
   write_byte(2);
 
-  if (!isSizeSwaped) {
+  if (!isSizeSwapped) {
     write_byte((0xff00 & size) >> 8);
     crc ^= (0xff00 & size) >> 8;
     write_byte(0xff & size);
@@ -377,7 +377,7 @@ static void
 globalsat_probe_device()
 {
   //TODO try this first if fails try with false, to support 561
-  isSizeSwaped = FALSE;                //all devices but gh561 since gh561 has swaped size.
+  isSizeSwapped = false;               //all devices but gh561 since gh561 has swaped size.
 
   globalsat_send_simple(CommandWhoAmI);
 
index c4d4edaa86686916f27d963a5103ce607193855a..cc3b7f165767c6bbc8ca9c73a8ce212f141fb131 100644 (file)
@@ -282,15 +282,15 @@ read_word()
  *
  * handle_nak determines behaviour when a PID_NAK packet is read from
  * the device:
- *  - if handle_nak is FALSE, a fatal error will be raised.
- *  - if handle_nak is TRUE, read_packet will simply return FALSE.
+ *  - if handle_nak is false, a fatal error will be raised.
+ *  - if handle_nak is true, read_packet will simply return false.
  *
- * Returns TRUE if the packet was successfully read into payload.
+ * Returns true if the packet was successfully read into payload.
  */
-static int
+static bool
 read_packet(unsigned type, void* payload,
             unsigned minlength, unsigned maxlength,
-            int handle_nak)
+            bool handle_nak)
 {
   unsigned      size;
   unsigned      checksum;
@@ -316,7 +316,7 @@ read_packet(unsigned type, void* payload,
 
   if (data[0] != type) {
     if (handle_nak && data[0] == PID_NAK) {
-      return FALSE;
+      return false;
     }
 
     fatal(MYNAME ": Protocol error: Bad packet type (expected 0x%02x but got 0x%02x)\n", type, data[0]);
@@ -339,7 +339,7 @@ read_packet(unsigned type, void* payload,
 
   xfree(data);
 
-  return TRUE;
+  return true;
 }
 
 static QDateTime
@@ -475,7 +475,7 @@ serial_read_waypoints()
   write_packet(PID_QRY_INFORMATION, nullptr, 0);
   read_packet(PID_DATA, information,
               sizeof(information), sizeof(information),
-              FALSE);
+              false);
 
   unsigned short total = le_read16(information + 0);
 
@@ -495,7 +495,7 @@ serial_read_waypoints()
 
     unsigned char*  waypoints = (unsigned char*) xmalloc(count * 32);
 
-    read_packet(PID_DATA, waypoints, count * 32, count * 32, FALSE);
+    read_packet(PID_DATA, waypoints, count * 32, count * 32, false);
 
     for (unsigned char*  w = waypoints; w < waypoints + count * 32; w = w + 32) {
       if (global_opts.masked_objective & WPTDATAMASK) {
@@ -524,7 +524,7 @@ serial_write_waypoint_packet(const Waypoint* waypt)
 
   encode_waypoint(waypt, data);
   write_packet(PID_ADD_A_WAYPOINT, data, sizeof(data));
-  if (!read_packet(PID_DATA, id, sizeof(id), sizeof(id), TRUE)) {
+  if (!read_packet(PID_DATA, id, sizeof(id), sizeof(id), true)) {
     fatal(MYNAME ": Could not write waypoint.\n");
   }
 
@@ -545,7 +545,7 @@ serial_read_track()
   write_packet(PID_QRY_INFORMATION, nullptr, 0);
   read_packet(PID_DATA, information,
               sizeof(information), sizeof(information),
-              FALSE);
+              false);
 
   unsigned int address = le_read32(information + 4);
   unsigned short total = le_read16(information + 12);
@@ -565,7 +565,7 @@ serial_read_track()
 
     unsigned char*  trackpoints = (unsigned char*) xmalloc(count * 32);
 
-    read_packet(PID_DATA, trackpoints, count * 32, count * 32, FALSE);
+    read_packet(PID_DATA, trackpoints, count * 32, count * 32, false);
     write_packet(PID_ACK, nullptr, 0);
 
     for (unsigned char*  t = trackpoints; t < trackpoints + count * 32; t = t + 32) {
@@ -588,7 +588,7 @@ serial_write_track()
   write_packet(PID_QRY_INFORMATION, nullptr, 0);
   read_packet(PID_DATA, information,
               sizeof(information), sizeof(information),
-              FALSE);
+              false);
 
   unsigned int address = le_read32(information + 4);
   unsigned short total = le_read16(information + 12);
@@ -600,7 +600,7 @@ serial_write_track()
   write_packet(PID_WRITE_TRACKPOINTS, data, sizeof(data));
   gb_sleep(10000);
   write_packet(PID_DATA, track_data, track_data_ptr - track_data);
-  read_packet(PID_CMD_OK, nullptr, 0, 0, FALSE);
+  read_packet(PID_CMD_OK, nullptr, 0, 0, false);
 
   track_data_ptr = track_data;
 }
@@ -643,7 +643,7 @@ serial_read_routes(Waypoint** waypts)
   write_packet(PID_QRY_INFORMATION, nullptr, 0);
   read_packet(PID_DATA, information,
               sizeof(information), sizeof(information),
-              FALSE);
+              false);
 
   unsigned char routec = information[2];
 
@@ -656,7 +656,7 @@ serial_read_routes(Waypoint** waypts)
     payload[6] = 0x01;
 
     write_packet(PID_QRY_ROUTE, payload, sizeof(payload));
-    read_packet(PID_DATA, routedata, 64, sizeof(routedata), FALSE);
+    read_packet(PID_DATA, routedata, 64, sizeof(routedata), false);
 
     route_head*    route = route_head_alloc();
     route->rte_num = routedata[2];
@@ -756,7 +756,7 @@ serial_write_route_end(const route_head* route)
   }
 
   write_packet(PID_ADD_A_ROUTE, data, 32 + src * 32);
-  if (!read_packet(PID_DATA, id, sizeof(id), sizeof(id), TRUE)) {
+  if (!read_packet(PID_DATA, id, sizeof(id), sizeof(id), true)) {
     fatal(MYNAME ": Could not add route.\n");
   }
 
@@ -841,7 +841,7 @@ read_datalog_info(unsigned int* seg1_addr, unsigned int* seg1_len,
   unsigned char  info[16];
 
   write_packet(PID_INFO_DATALOG, nullptr, 0);
-  read_packet(PID_DATA, info, sizeof(info), sizeof(info), FALSE);
+  read_packet(PID_DATA, info, sizeof(info), sizeof(info), false);
 
   unsigned int flash_start_addr = le_read32(info);
   unsigned int flash_length = le_read32(info + 4);
@@ -885,7 +885,7 @@ read_datalog_records(route_head* track,
     payload[6] = 0x01;
 
     write_packet(PID_READ_DATALOG, payload, sizeof(payload));
-    read_packet(PID_DATA, logpoints, logpoints_len, logpoints_len, FALSE);
+    read_packet(PID_DATA, logpoints, logpoints_len, logpoints_len, false);
     write_packet(PID_ACK, nullptr, 0);
 
     for (unsigned char* p = logpoints; p < logpoints + logpoints_len; p += 32) {
@@ -1007,14 +1007,14 @@ nuke()
     write_packet(PID_QRY_INFORMATION, nullptr, 0);
     read_packet(PID_DATA, information,
                 sizeof(information), sizeof(information),
-                FALSE);
+                false);
 
     le_write32(data + 0, le_read32(information + 4));
     le_write16(data + 4, 0);
     data[6] = 0;
 
     write_packet(PID_ERASE_TRACK, data, sizeof(data));
-    read_packet(PID_CMD_OK, nullptr, 0, 0, FALSE);
+    read_packet(PID_CMD_OK, nullptr, 0, 0, false);
   }
 
   if (nukerte) {
@@ -1022,7 +1022,7 @@ nuke()
 
     le_write32(data, 0x00f00000);
     write_packet(PID_DEL_ALL_ROUTE, data, sizeof(data));
-    if (!read_packet(PID_ACK, nullptr, 0, 0, TRUE)) {
+    if (!read_packet(PID_ACK, nullptr, 0, 0, true)) {
       fatal(MYNAME ": Could not nuke all routes.\n");
     }
   }
@@ -1032,7 +1032,7 @@ nuke()
 
     le_write32(data, 0x00f00000);
     write_packet(PID_DEL_ALL_WAYPOINT, data, sizeof(data));
-    if (!read_packet(PID_ACK, nullptr, 0, 0, TRUE)) {
+    if (!read_packet(PID_ACK, nullptr, 0, 0, true)) {
       fatal(MYNAME ": You must nuke all routes before nuking waypoints.\n");
       /* perhaps a better action would be to nuke routes for user.
        * i.e. set nukerte when nukewpt is set */
@@ -1046,7 +1046,7 @@ nuke()
      * So give the device some time to clear its datalog, in addition
      * to SERIAL_TIMEOUT, which applies to read_packet() */
     gb_sleep(CLEAR_DATALOG_TIME * 1000);
-    read_packet(PID_ACK, nullptr, 0, 0, FALSE);
+    read_packet(PID_ACK, nullptr, 0, 0, false);
   }
 }
 
@@ -1063,7 +1063,7 @@ navilink_common_init(const QString& name)
     }
 
     write_packet(PID_SYNC, nullptr, 0);
-    read_packet(PID_ACK, nullptr, 0, 0, FALSE);
+    read_packet(PID_ACK, nullptr, 0, 0, false);
 
     /* nuke data before writing */
     if (operation == WRITING) {
index 99a89e86e5fabc73d6fc1f42b5039d0bc2c94c4d..1f3731ef83e85128d59577d77359bb7e6ee9ad78 100644 (file)
@@ -33,7 +33,7 @@ Waypoint* navilink_decode_logpoint(const unsigned char* buffer);
 unsigned navilink_checksum_packet(const unsigned char* packet, unsigned length);
 
 /* defined in sbn.c */
-int locosys_decode_file_id(char* header, size_t len);
+bool locosys_decode_file_id(char* header, size_t len);
 
 
 #ifdef THIS_IS_ONLY_FOR_REFERENCE
diff --git a/sbn.cc b/sbn.cc
index 69022614ce91b4cd5196ad1c88017d4f8d0cd691..97cb659831f68ec65cf0c26ab37f244f4b3fad8f 100644 (file)
--- a/sbn.cc
+++ b/sbn.cc
@@ -131,7 +131,7 @@ hdrcpy(char* dest, const char* src, size_t max_len)
 }
 #endif /* LOCOSYS_PARSE_FILE_ID */
 
-int
+bool
 locosys_decode_file_id(char* header, size_t len)
 {
   Q_UNUSED(header);
@@ -164,7 +164,7 @@ locosys_decode_file_id(char* header, size_t len)
   printf(MYNAME ": Firmware version: %s\n", version);
 #endif /* LOCOSYS_PARSE_FILE_ID */
 
-  return TRUE;
+  return true;
 }
 
 static void
diff --git a/sbp.cc b/sbp.cc
index 71688545b8dac3ceedb6aed9cb12aa69aa348a69..095d48d31b5f1712ca6c55c4b0ae7240cd548dac 100644 (file)
--- a/sbp.cc
+++ b/sbp.cc
@@ -62,7 +62,7 @@ read_sbp_header(route_head*)
 
 #define HEADER_SKIP 7
 
-  int success;
+  bool success;
   char header[64];
 
   if (gbfread(header, sizeof(header), 1, file_handle) == 1) {
@@ -73,7 +73,7 @@ read_sbp_header(route_head*)
 
     success = locosys_decode_file_id(header + HEADER_SKIP, len);
   } else {
-    success = FALSE;
+    success = false;
   }
 
   if (!success) {